package com.example.mountainwalker.mapper;

import com.example.mountainwalker.entity.HotelImageInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface HotelImageMapper {
    // 查询所有酒店图片
    @Select("SELECT * FROM HotelImage")
    List<HotelImageInfo> getAllHotelImages();

    // 根据ID查询酒店图片
    @Select("SELECT * FROM HotelImage WHERE HotelImageID = #{id}")
    HotelImageInfo getHotelImageById(@Param("id") Integer id);

    // 新增酒店图片
    @Insert("INSERT INTO HotelImage(HotelImageID,HotelID, HotelImageLink) VALUES(#{hotelImageID},#{hotelID}, #{hotelImageLink})")
    @Options(useGeneratedKeys = true, keyProperty = "hotelImageID")
    int insertHotelImage(HotelImageInfo hotelImageInfo);

    // 更新酒店图片
    @Update("UPDATE HotelImage SET HotelID=#{hotelID}, HotelImageLink=#{hotelImageLink} WHERE HotelImageID=#{hotelImageID}")
    int updateHotelImage(HotelImageInfo hotelImageInfo);

    // 删除酒店图片
    @Delete("DELETE FROM HotelImage WHERE HotelImageID=#{id}")
    int deleteHotelImage(@Param("id") Integer id);

    // 根据酒店ID查询图片
    @Select("SELECT * FROM HotelImage WHERE HotelID = #{hotelId}")
    List<HotelImageInfo> getImagesByHotelId(@Param("hotelId") Integer hotelId);
}